Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boost: ignore dependency if it doesn't provide a library [v1] #23478

Merged
merged 1 commit into from
Apr 23, 2024

Conversation

kambala-decapitator
Copy link
Contributor

Specify library name and version: boost/any

For Conan v1 I use the following custom recipes that wrap system libraries on Apple platforms:

But when I try to build Boost against those, it fails due to attempt to access first element of an empty array. This patch prevents that.

Tested by building Boost as shared library and my project and then running my project successfully.


@CLAassistant
Copy link

CLAassistant commented Apr 11, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

🤖 Beep Boop! This pull request is making changes to 'recipes/boost//'.

👋 @grafikrobot @Hopobcn @jwillikers @paulharris you might be interested. 😉

@conan-center-bot

This comment has been minimized.

@ghost
Copy link

ghost commented Apr 11, 2024

@uilianries
Copy link
Member

@kambala-decapitator Thank you for your PR! This current Boost recipe is linking to both zlib and bzip2 libraries present in Conan Center and is working. Why do you need these custom recipes instead of using the officials?

Plus, could you please share your full build log with your described error?

@uilianries uilianries self-assigned this Apr 11, 2024
@kambala-decapitator
Copy link
Contributor Author

@kambala-decapitator Thank you for your PR! This current Boost recipe is linking to both zlib and bzip2 libraries present in Conan Center and is working. Why do you need these custom recipes instead of using the officials?

Plus, could you please share your full build log with your described error?

@uilianries I'd like to use system libraries - the less custom dependencies the better :) This has worked great with a few other libraries from CCI. I know that v2 has a built-in way to declare system libs, but currently our project is still using v1.

sorry, don't have the build log at hand any more, but initially it said something like "index out of bounds" pointing at the line

includedir = aggregated_cpp_info.includedirs[0].replace("\\", "/")

at first I modified my custom recipes to include library name in libs as well as empty string in includedirs and libdirs (arrays that access the first element) and boost built successfully, but then at cmake configure time it started complaining

-- Conan: Target declared 'BZip2::BZip2'
CMake Error at conan-generated/cmakedeps_macros.cmake:39 (message):
  Library 'bz2' not found in package.  If 'bz2' is a system library, declare
  it with 'cpp_info.system_libs' property
Call Stack (most recent call first):
  conan-generated/BZip2-Target-release.cmake:24 (conan_package_library_targets)
  conan-generated/BZip2Targets.cmake:26 (include)
  conan-generated/BZip2Config.cmake:16 (include)
  /usr/local/Cellar/cmake/3.29.1/share/cmake/Modules/CMakeFindDependencyMacro.cmake:76 (find_package)
  conan-generated/BoostConfig.cmake:24 (find_dependency)
  CMakeLists.txt:462 (find_package)

you can see full log at https://github.com/vcmi/vcmi/actions/runs/8637368273/job/23679378148

And with the current patch it all builds and works perfectly.

@uilianries
Copy link
Member

I'd like to use system libraries - the less custom dependencies the better :) This has worked great with a few other libraries from CCI. I know that v2 has a built-in way to declare system libs, but currently our project is still using v1.

@kambala-decapitator Sorry, I still miss the big picture, because you are actually using a Conan package for Boost, but can not use for zlib and bzip2? Those packages are built exactly as recommended by the upstream and most excepted in Linux distros, we usually compare patches from distros linux like Ubuntu and from AUR to make sure. Also, you can build from source all packages and inspect the recipe exported, in case you have security reasons. Is there something wrong with those packages that we could improve?

at first I modified my custom recipes to include library name in libs as well as empty string in includedirs and libdirs (arrays that access the first element) and boost built successfully, but then at cmake configure time it started complaining

Yes, packaging system libraries is a bit more complicated. You can use some recipes from CCI as reference:

you can see full log at vcmi/vcmi/actions/runs/8637368273/job/23679378148

Thank you for sharing!

@jwillikers
Copy link
Contributor

jwillikers commented Apr 11, 2024

@uilianries I've run into a similar problem elsewhere when using platform_requires for a system package. Trying to use cpp_info of system libraries can be problematic because the libs or certain other bits may not be set, at least when using platform_requires. Of course, this case appears to be a bit different.

@jwillikers
Copy link
Contributor

@kambala-decapitator You might try setting the libs and libdirs variables appropriately. Ideally you could use pkg-config which handles transitive dependencies, but if I remember correctly, bzip doesn't provide one yet. They have one in master I think.

@uilianries
Copy link
Member

@uilianries I've run into a similar problem elsewhere when using platform_requires for a system package. Trying to use cpp_info of system libraries can be problematic because the libs or certain other bits may not be set, at least when using platform_requires. Of course, this case appears to be a bit different.

@jwillikers Thank you for your comment. Indeed accessing an index that could be empty is a bug, I'm not in the opposite of fixing the recipe in case having something broken. But first I would like to understand this scenario. When you mention a system package, did you refer a package like (e.g) gtk/system from ConanCenter?

@jwillikers
Copy link
Contributor

@uilianries I've run into a similar problem elsewhere when using platform_requires for a system package. Trying to use cpp_info of system libraries can be problematic because the libs or certain other bits may not be set, at least when using platform_requires. Of course, this case appears to be a bit different.

@jwillikers Thank you for your comment. Indeed accessing an index that could be empty is a bug, I'm not in the opposite of fixing the recipe in case having something broken. But first I would like to understand this scenario. When you mention a system package, did you refer a package like (e.g) gtk/system from ConanCenter?

In my case, I had to add the include directories from the cpp_info of the linux-headers-generic package as part of the setup in the generate method of a package. When I used a platform_requires to use the system's Linux headers, accessing the include directories for it failed.

@conan-center-bot

This comment has been minimized.

@kambala-decapitator
Copy link
Contributor Author

@uilianries @jwillikers thank you for the responses!

you are actually using a Conan package for Boost, but can not use for zlib and bzip2?

Apple OSs have these libraries in the system (I also have custom recipes to wrap iconv and sqlite3 btw) and I want to use them instead of building them from source. It's common practice in Apple world to use these built-in libraries in programs. I don't think that I must use them from CCI only?

Yes, packaging system libraries is a bit more complicated. You can use some recipes from CCI as reference:

these examples install something from package managers. I don't need this, all the aforementioned libs are present in a freshly installed OS.

You might try setting the libs and libdirs variables appropriately

yes, that's what I tried initially. But once I set libs, then cmake configuration of my project fails, see #23478 (comment)


btw I've just thought of this: would it make more sense to adjust the patch to check if system_libs is present and return empty string in that case?

P.S. Do I need to take any action because of the unexpected build error?

@ghost ghost mentioned this pull request Apr 16, 2024
3 tasks
@kambala-decapitator
Copy link
Contributor Author

@uilianries please check my above comment

@ghost ghost mentioned this pull request Apr 19, 2024
3 tasks
@conan-center-bot

This comment has been minimized.

@conan-center-bot
Copy link
Collaborator

Conan v1 pipeline ✔️

All green in build 7 (6a049044f02fa89fae38e9b0325beb53bf23b66e):

  • boost/1.83.0:
    All packages built successfully! (All logs)

  • boost/1.79.0:
    All packages built successfully! (All logs)

  • boost/1.81.0:
    All packages built successfully! (All logs)

  • boost/1.78.0:
    All packages built successfully! (All logs)

  • boost/1.84.0:
    All packages built successfully! (All logs)

  • boost/1.76.0:
    All packages built successfully! (All logs)

  • boost/1.75.0:
    All packages built successfully! (All logs)

  • boost/1.74.0:
    All packages built successfully! (All logs)

  • boost/1.72.0:
    All packages built successfully! (All logs)

  • boost/1.71.0:
    All packages built successfully! (All logs)

  • boost/1.80.0:
    All packages built successfully! (All logs)

  • boost/1.73.0:
    All packages built successfully! (All logs)

  • boost/1.82.0:
    All packages built successfully! (All logs)

  • boost/1.77.0:
    All packages built successfully! (All logs)


Conan v2 pipeline ✔️

Note: Conan v2 builds are now mandatory. Please read our discussion about it.

All green in build 7 (6a049044f02fa89fae38e9b0325beb53bf23b66e):

  • boost/1.84.0:
    All packages built successfully! (All logs)

  • boost/1.83.0:
    All packages built successfully! (All logs)

  • boost/1.81.0:
    All packages built successfully! (All logs)

  • boost/1.82.0:
    All packages built successfully! (All logs)

  • boost/1.80.0:
    All packages built successfully! (All logs)

  • boost/1.77.0:
    All packages built successfully! (All logs)

  • boost/1.78.0:
    All packages built successfully! (All logs)

  • boost/1.71.0:
    All packages built successfully! (All logs)

  • boost/1.73.0:
    All packages built successfully! (All logs)

  • boost/1.72.0:
    All packages built successfully! (All logs)

  • boost/1.74.0:
    All packages built successfully! (All logs)

  • boost/1.75.0:
    All packages built successfully! (All logs)

  • boost/1.79.0:
    All packages built successfully! (All logs)

  • boost/1.76.0:
    All packages built successfully! (All logs)

Copy link
Contributor

Hooks produced the following warnings for commit 6a04904
boost/1.83.0@#163e26b9dc12e73728e4d3c489bec1bd
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log.dll' links to system library 'secur32' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log.dll' links to system library 'ws2_32' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log_setup.dll' links to system library 'ws2_32' but it is not in cpp_info.system_libs.
boost/1.79.0@#ae4c3d4fd92f165ba6fb2c075f4c8c0d
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log.dll' links to system library 'ws2_32' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log_setup.dll' links to system library 'ws2_32' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log.dll' links to system library 'secur32' but it is not in cpp_info.system_libs.
boost/1.81.0@#b8dc4d6077ea9c27851f39511ef48c72
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log.dll' links to system library 'secur32' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log.dll' links to system library 'ws2_32' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log_setup.dll' links to system library 'ws2_32' but it is not in cpp_info.system_libs.
boost/1.78.0@#e7cdfcfabf40a7be163a3eba83ce25b7
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log.dll' links to system library 'ws2_32' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log_setup.dll' links to system library 'ws2_32' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log.dll' links to system library 'secur32' but it is not in cpp_info.system_libs.
boost/1.84.0@#1a56e4b40ceccf6b196212cd43e3e5c5
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log.dll' links to system library 'secur32' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log.dll' links to system library 'ws2_32' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log_setup.dll' links to system library 'ws2_32' but it is not in cpp_info.system_libs.
boost/1.76.0@#54dc2458ed92237bedf4a66750c982c7
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log.dll' links to system library 'secur32' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log.dll' links to system library 'ws2_32' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log_setup.dll' links to system library 'ws2_32' but it is not in cpp_info.system_libs.
boost/1.75.0@#eee9e434747e0daa298bd1ef233c16f1
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log.dll' links to system library 'ws2_32' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log_setup.dll' links to system library 'ws2_32' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log.dll' links to system library 'secur32' but it is not in cpp_info.system_libs.
boost/1.72.0@#19d559550a786c9e125eab94c22cdc36
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log.dll' links to system library 'secur32' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log.dll' links to system library 'ws2_32' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log_setup.dll' links to system library 'ws2_32' but it is not in cpp_info.system_libs.
boost/1.71.0@#c65a1cabc521931a5d4789e45fa23606
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log.dll' links to system library 'ws2_32' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log_setup.dll' links to system library 'ws2_32' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log.dll' links to system library 'secur32' but it is not in cpp_info.system_libs.
boost/1.73.0@#d3cca0e6b1455648a1a01baa489546d2
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log.dll' links to system library 'secur32' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log.dll' links to system library 'ws2_32' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log_setup.dll' links to system library 'ws2_32' but it is not in cpp_info.system_libs.
boost/1.82.0@#b5964bcd3a243037f377fd0005fc93c6
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log.dll' links to system library 'ws2_32' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log_setup.dll' links to system library 'ws2_32' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log.dll' links to system library 'secur32' but it is not in cpp_info.system_libs.
boost/1.77.0@#1582d872291de21ded575482b9f41972
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log.dll' links to system library 'secur32' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log.dll' links to system library 'ws2_32' but it is not in cpp_info.system_libs.
post_package(): WARN: [MISSING SYSTEM LIBS (KB-H043)] Library '.\bin\boost_log_setup.dll' links to system library 'ws2_32' but it is not in cpp_info.system_libs.

@uilianries
Copy link
Member

Apple OSs have these libraries in the system (I also have custom recipes to wrap iconv and sqlite3 btw) and I want to use them instead of building them from source. It's common practice in Apple world to use these built-in libraries in programs. I don't think that I must use them from CCI only?

@kambala-decapitator Thank you for more details about your case. Could please refer a source about this common practice in Apple world? I've never heard about, so I'm curious. The problem using system dependencies is tracking the changes and reproducing the same build with total safety. You are totally free to mix Conan packages with system packages at your risk, if this enough to cover your case, so is totally fine :)

Copy link
Member

@uilianries uilianries left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@conan-center-bot conan-center-bot merged commit 3befde3 into conan-io:master Apr 23, 2024
84 checks passed
@kambala-decapitator kambala-decapitator deleted the patch-1 branch April 23, 2024 07:49
@kambala-decapitator
Copy link
Contributor Author

@uilianries thanks for the merge!

I don't have a source in the sense of an article from documentation, but if you open any Xcode project and go to the Link Binary With Libraries section, you can select a wide range of system libraries (besides frameworks) there, see SS. When one works purely with Xcode project, it's common to choose libraries from there.

Screenshot 2024-04-23 at 10 53 21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants